#ifndef WINDOWMANAGER_H
#define WINDOWMANAGER_H

#include <QThread>
#include <QMap>
#include <QMutex>

#include "watermarkwindow.h"

class WindowManager : public QObject
{
    Q_OBJECT
public:
    explicit WindowManager(QObject *parent = nullptr);
    virtual ~WindowManager();

    void start();
    void stop();

    QStringList processList() const;
    void setProcessList(const QStringList &processList);

signals:
    void enumWindows();
    void onEnumWindows(const QList<WindowInfo> &windowInfos);

public slots:
    void slotCreateWindow(const QList<WindowInfo> &windowInfos);
    void slotQuitWindow(const WID &wid);
    void slotUpdateWatermarkWindow();

    void slotOnProcessChanged(const QString &process, int changed);

private:
    static WatermarkWindow *createWatermarkWindow(const WindowInfo &windowInfo);

private:
    QThread m_thread;
    QMutex m_mutex;

    QStringList m_processList;

    QMap<WID, WatermarkWindow *> m_watermarkWindows;
};

#endif // WINDOWMANAGER_H
